/*******************************************************************************
 * @file Food.h
 * Definition of the CFood class.
 * 
 * @package Dining.
 * 
 * @author mk
 * @date 03/01/2008 13:50:21
 * @version 0.1
 ******************************************************************************/

#ifndef __FOOD_H_INCLUDED__
#define __FOOD_H_INCLUDED__

#include <boost/thread/mutex.hpp>

/** @brief Project related classes are scoped by this namespace. */
namespace Dining
{	
	/** @brief Class for defining a spoon. */
	class CFood
	{
	public:
		/** Default constructor. Conversion disallowed. */
		explicit CFood(unsigned int anAmount = 1) :
			m_Portions(anAmount), m_Amount(anAmount) 
		{}
		
		/** Take a portion. Not threadsafe. */
		bool Take(unsigned int anAmount = 1);
		
		/** Take a portion. Threadsafe. */
		bool Take(unsigned int anAmount = 1) volatile;

		/** Get the amount of available portions. Not threadsafe. */
		unsigned int GetAmount();

		/** Get the amount of available portions. Threadsafe. */
		unsigned int GetAmount() volatile;

		const unsigned int m_Portions;	///< has an initial value of food

	private:
		/** Asignment operator made private for disallowing copy assignment. */
		CFood& operator= (const CFood& /*aFood*/);

		/** Copy constructor made private for disallowing copy construction. */
		CFood(const CFood& /*aFood*/);
		
		unsigned int m_Amount;			///< has an amount (shows how much is left in the food bowl)
		boost::mutex m_Mutex;			///< has a mutex (the food bowl is accessed exlusively)		
	};	
}

#endif /* __FOOD_H_INCLUDED__ */
